"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""

record = []


class TenXClass:
    def __init__(self):
        self.name = "廖镔"
        self.id = "3124002014"

    @staticmethod
    def question1(n: int) -> list[str]:
        def change(num):
            text = ""
            while num > 0:
                text = str(num % 4) + text
                num = num // 4
            return text

        return [change(i) for i in range(1, n + 1)]

    @staticmethod
    def question2() -> list[tuple[int, int, int]]:
        return [(0, 25, 75), (4, 18, 78), (8, 11, 81), (12, 4, 84)]

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        sort_dict = {"equipment": [], "prop": [], "material": []}
        for i in items:
            if i in equipment:
                sort_dict["equipment"].append(i)
                continue
            if i in prop:
                sort_dict["prop"].append(i)
                continue
            if i in material:
                sort_dict["material"].append(i)
        return sort_dict

    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        sorted_list, num, item_record, max_value = sorted(item_values.items(), key=lambda dic: (dic[1], dic[0]),
                                                          reverse=True), 0, [], 0
        for key, value in sorted_list:
            for item in items:
                if num == 3:
                    break
                if key == item:
                    num += 1
                    item_record.append(item)
                    max_value += value

        return item_record, max_value

    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        return [(i + 1, j + 1) for i, row in enumerate(matrix) for j, value in enumerate(row) if value == 0]
